#include <stdio.h>

#include <vector>

using namespace std;

vector <vector <int> > graph;

int n;

vector <int> color;

void dfs(int x)
{
    color[x] = 1;
    for(int i = 0; i < graph[x].size(); i++)
    {
        if(color[graph[x][i]] == 0)
        {
            dfs(graph[x][i]);
        }
    }
    printf("%i ", x + 1);
}


int main()
{
    scanf("%i", &n);
    int a;
    int i, j;
    graph.resize(n);
    for(i = 0; i < n; i++)
        graph[i].resize(0);
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            scanf("%i", &a);
            if(a == 1)
              graph[i].push_back(j);
        }
       // scanf("\n");
    }
    color.resize(n, 0);
    for(i = 0; i < n; i++)
    {
        if(color[i] == 0)
        {
            dfs(i);
            printf("\n");
        }
    }
}
